import {url,axios} from '.';

export const listType = async (current,pageSize) => {
    let res = await axios({
        method: 'get',
        url: `${url}/types`,
        params:{
            current,pageSize
        }
    });
    return res.data;
}
export const listAllType = async () => {
    let res = await axios({
        method: 'get',
        url: `${url}/types/all`
    });
    return res.data;
}

export const getTypeById = async (id) => {
    let res = await axios({
        method: 'get',
        url: `${url}/types/${id}`
    });
    return res.data;
}
export const addType = async (type) => {
    let res = await axios({
        method: 'post',
        url: `${url}/types`,
        data:type
    });
    return res.data;
}
export const updateType = async (type) => {
    let res = await axios({
        method: 'put',
        url: `${url}/types/${type.id}`,
        data:type
    });
    return res.data;
}
export const updateTypeIndex = async (id,val) => {
    let res = await axios({
        method: 'put',
        url: `${url}/types/index/${id}`,
        data:{
            val
        }
    });
    return res.data;
}